<?php
/**
 * Created by PhpStorm.
 * User: minicart
 * Date: 2018/9/21
 * Time: 16:17
 */
namespace app\models;
use think\Model;

/**
 * Class ZanModel
 * @package app\models
 */
class ExecuteTaskModel extends Model
{
    protected $table = 'edu_execute_task';

    /***
        刷新数据库绑定关系标志
     */
    public function RefreshStatus(){
        $timestamp = time();
        $data = [];

        $result = self::select();
        foreach ($result as $key => $value){
           if($timestamp >=  $result[$key]['end_execute_time'] &&  $result[$key]['status']  == 1){  //绑定的超过时间时间的教室
              $data[$key]['id'] =  $result[$key]['id'];
              $data[$key]['status'] = 0;  //解绑0:未绑定 1:已绑定
            }
        }

       if(count($data) > 0){
            self::saveAll($data);  //更新
       }
    }
}